<%--
  Created by IntelliJ IDEA.
  User: zhangyuan
  Date: 2020-03-16
  Time: 13:28
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>我的会议</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css?20190817.1">
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/lib/layui/layui/layui.js"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script src="/lib/layui/layui/js/common.js?v=20190726" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/baseCode/base.js?v=2019080918:09" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/HSTmeeting/base64.js" type="text/javascript"></script>
    <script src="/js/HSTmeeting/entermeeting.js?sid=2b2f9c37241432a91dc2f9343f5e4053" type="text/javascript"></script>
    <script src="../js/webOffice/fileShow.js" type="text/javascript" charset="utf-8"></script>
    <style>
        .download_a{
            color: blue;
        }
    </style>
</head>
<body>
<iframe id="myiframe" name="myiframe" style="display:none;" src=""></iframe>
<div class="headImg" style="margin-top: 10px">
    <span style="font-size:22px;margin-left:10px;color:#494d59;margin-top: 2px"><img style="margin-left:1.5%" src="../img/commonTheme/theme6/icon_summary.png" alt=""><span style="margin-left: 10px">我的会议</span></span>
</div>
<hr>
<div style="padding: 8px;margin-left: 1.5%;margin-right: 1.5%;margin-top: -15px">
    <table id="meet" lay-filter="meet"></table>
</div>
    <script type="text/html" id="barDemo">
        <%--<a class="layui-btn layui-btn-xs" lay-event="detail" >详情</a>--%>
        {{#  if(d.advanceMinString == 1 || d.meetStatus==3 || d.meetStatus==5 ){ }}
        <a class="layui-btn layui-btn-xs" lay-event="join" >参加会议</a>
        {{#  } }}
    </script>
    <script>
        var form
        var tableIns
        //服务器地址定义
        var address ;
        layui.use(['table','form'], function(){
            var table = layui.table;
            form = layui.form;
            //第一个实例
            tableIns= table.render({
                elem: '#meet'
                ,url: '/hstMeetingRoom/myHstMeetings' //数据接口
                ,where:{
                    useFlag:true
                }
                ,cols: [[ //表头
                    {field: 'meetName', title: '会议名称' , align:'center',event: 'detailName', style:'cursor: pointer;color:blue'}
                    ,{field: 'subject', title: '会议主题' , align:'center'}
                    ,{field: 'roomName', title: '会议室',align:'center',event: 'detail', style:'cursor: pointer;color:blue'}
                    // ,{field: 'userIdName', title: '申请人', align:'center'}
                    ,{field: 'startTime', title: '开始时间',align:'center'}
                    // ,{field: 'endTime', title: '结束时间',align:'center' }
                    ,{field: 'meetStatusString', title: '会议状态', align:'center'}
                    ,{ title: '操作',align:'center', toolbar: '#barDemo'} //这里的toolbar值是模板元素的选择器
                ]]
                ,page: true //开启分页
                ,parseData: function(res){ //res 即为原始返回的数据
                    return {
                        "code": 0, //解析接口状态
                        "data": res.obj,//解析数据列表
                        "count": res.totleNum, //解析数据长度
                    };
                }
                ,request: {
                    pageName: 'page' //页码的参数名称，默认：page
                    ,limitName: 'pageSize' //每页数据量的参数名，默认：limit
                }
            });
            //监听工具条
            table.on('tool(meet)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data; //获得当前行数据
                var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
                var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）
                console.log(data)
                var hstRoomWithBLOBs=data.hstRoomWithBLOBs
                if(layEvent === 'join'){ //删除
                    layer.confirm('确定要参加会议吗？', function(index){
                        address=data.hstRoomWithBLOBs.serverAddr
                        entermeeting(data.hstRoomWithBLOBs.roomNo,data.hstRoomWithBLOBs.roomPwd,data.userNameString)
                        layer.close(index);
                    });
                }else if(layEvent === 'detailName'){
                    $.ajax({
                        url:'/hstMeetingRoom/queryHstMeetingById',
                        type: "post",
                        dataType: "json",
                        data:{meetId:data.meetingId},
                        success:function (res) {
                            var data=res.object
                            layer.open({
                                type: 1,
                                title: '会议详情',
                                shade: 0.5,
                                area: ['50%', '80%'],
                                content:'<form class="layui-form" id="ajaxforms" lay-filter="formsTest" style="width:90%;margin-left:5%;margin-top: 3%;">' +
                                        '<table class="layui-table">\n' +
                                    '  <tbody>\n' +
                                  /*  '    <tr>\n' +
                                    '      <td nowrap="nowrap" style="width:20%">会议室名称:</td>\n' +
                                    '      <td class="roomName">' +data.roomName+
                                    '</td>\n' +
                                    '    </tr>\n' +*/
                                    '    <tr>\n' +
                                    '      <td nowrap="nowrap" style="width:20%">会议名称:</td>\n' +
                                    '      <td class="meetName">'+data.meetName+'</td>\n' +
                                    '    </tr>\n' +
                                    '    <tr>\n' +
                                    '      <td nowrap="nowrap">会议主题:</td>\n' +
                                    '      <td class="subject">'+data.subject+'</td>\n' +
                                    '    </tr>\n' +
                                    '    <tr>\n' +
                                    '      <td nowrap="nowrap">参会人员:</td>\n' +
                                    '      <td class="userIdsName">'+data.userIdsName.substring(0,data.userIdsName.length-1)+'</td>\n' +
                                    '    </tr>\n' +
                                    '    <tr>\n' +
                                    '      <td nowrap="nowrap">开始时间:</td>\n' +
                                    '      <td class="startTime">'+data.startTime+'</td>\n' +
                                    '    </tr>\n' +
                                    '    <tr>\n' +
                                    '      <td nowrap="nowrap">结束时间:</td>\n' +
                                    '      <td class="endTime">'+data.endTime+'</td>\n' +
                                    '    </tr>\n' +
                                    '    <tr>\n' +
                                    '      <td nowrap="nowrap">审批人:</td>\n' +
                                    '      <td class="managerIdName">'+data.managerIdName.substring(0,data.managerIdName.length-1)+'</td>\n' +
                                    '    </tr>\n' +
                                    '    <tr>\n' +
                                    '      <td nowrap="nowrap">提前进入会议室时间:</td>\n' +
                                    '      <td class="advanceMin">'+function () {
                                        if(data.advanceMin==0){
                                            return  '按时进入会议'
                                        }else {
                                            return data.advanceMin+'分钟'
                                        }
                                    }()+'</td>\n' +
                                    '    </tr>\n' +
                                    '    <tr>\n' +
                                    '      <td nowrap="nowrap">附件:</td>\n' +
                                    '      <td class="Table">'+function () {
                                       /* var arrAttach2 = res.object.attachmentList;
                                        var stra2 = '';
                                        if (arrAttach2 && arrAttach2.length > 0){
                                            for(var i=0;i<arrAttach2.length;i++){
                                                stra2+= '<div class="dech" style="max-width: 550px;" deUrl="' + encodeURI(arrAttach2[i].attUrl)+ '"><a title="'+ arrAttach2[i].attachName +'" style="display:inline-block;width:100%;overflow: hidden; word-break:break-all;white-space: nowrap;text-overflow: ellipsis;" href="<%=basePath %>download?'+encodeURI(arrAttach2[i].attUrl)+'" NAME="' + arrAttach2[i].attachName + '*"><img style="margin-right:10px;" src="../img/attachment_icon.png"/>' + arrAttach2[i].attachName + '</a></div>';
                                            }
                                        } else {
                                            stra2='无附件';
                                        }
                                        return stra2*/

                                    }()+'</td>\n' +
                                    '    </tr>\n' +
                                    '    <tr>\n' +
                                    '      <td nowrap="nowrap">会议描述:</td>\n' +
                                    '      <td class="meetDesc">'+data.meetDesc+'</td>\n' +
                                    '    </tr>\n' +
                                    '  </tbody>\n' +
                                    '</table>'+
                                    '</form>',
                                success:function(){
                                    var arr=res.object.attachmentList
                                    attachmentShow_news(arr,$('.Table'));
                                    for(var i=0;i<$('.font_').length;i++){
                                        $('.font_').eq(i).children(":first").remove()
                                    }
                                    $('.font_ .file_a  span').css('margin-left','12px')
                                }
                            })
                        }
                    })
                }else if(layEvent === 'detail'){
                    layer.open({
                        type: 1,
                        title: '会议室详情',
                        shade: 0.5,
                        area: ['40%', '53%'],
                        content:'<form class="layui-form" id="ajaxforms" lay-filter="formsTest" style="width:90%;margin-left:5%;margin-top: 3%;">' +
                            '<table class="layui-table">\n' +
                            '  <tbody>\n' +
                            '    <tr>\n' +
                            '      <td nowrap="nowrap" style="width:20%">会议室名称:</td>\n' +
                            '      <td class="meetName">'+hstRoomWithBLOBs.roomName+'</td>\n' +
                            '    </tr>\n' +
                            '    <tr>\n' +
                            '      <td nowrap="nowrap">会议室号:</td>\n' +
                            '      <td class="subject">'+hstRoomWithBLOBs.roomNo+'</td>\n' +
                            '    </tr>\n' +
                            '    <tr>\n' +
                            '      <td nowrap="nowrap">会议室密码:</td>\n' +
                            '      <td class="subject">'+hstRoomWithBLOBs.roomPwd+'</td>\n' +
                            '    </tr>\n' +
                            '    <tr>\n' +
                            '      <td nowrap="nowrap">服务器地址:</td>\n' +
                            '      <td class="subject">'+hstRoomWithBLOBs.serverAddr+'</td>\n' +
                            '    </tr>\n' +
                            '    <tr>\n' +
                            '      <td nowrap="nowrap">会议室管理员:</td>\n' +
                            '      <td class="userIdsName">'+hstRoomWithBLOBs.roomManagerName.substring(0,hstRoomWithBLOBs.roomManagerName.length-1)+'</td>\n' +
                            '    </tr>\n' +
                            '  </tbody>\n' +
                            '</table>'+
                            '</form>',
                    })
                }
            });
        });
        //PC客户端自动下载地址
        var clientForPCDownloadAddr = "http://www.hst.com/download/FMDesktop.exe";
        //登录会议室主函数
        function entermeeting(roomNo,roomPwd,nickName){
            var roomId = roomNo;
            var roomPwd = roomPwd;
            var userName = '';
            var userPwd = '';
            var nickName = nickName;

           /* if(!isValidInput(roomId, roomPwd, userName, userPwd, nickName)){
                alert("请输入必要的参数");

                return;
            }*/

            var url = getURLForPC(roomId, roomPwd, userName, userPwd, nickName);
            if (isAndroid) {
                url = getURLForAndroid(roomId, roomPwd, userName, userPwd, nickName);
            }else if(isiOS) {
                url = getURLForIphone(roomId, roomPwd, userName, userPwd, nickName);
            }
            if(its.x.isIE() || its.x.isChrome() || its.x.isSafari()){
                setTimeout(function(){
                    window.location.href = url;
                }, 1);
            }else{
                document.getElementById("myiframe").src = url;
            }
        }
        function getUserType(){
            var userType;
            var obj = document.getElementsByName("userType");
            for(var i = 0; i < obj.length; i++){
                if(obj[i].checked)
                    userType = obj[i].value;
            }
            return userType;
        }
    </script>
</body>
</html>
